<link href="css/style.css" rel="stylesheet">
<div data-ng-init="initialize()" data-ng-controller="HomepageController" id="wrapper">
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">

    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse"
                id="button-toggle">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="/" style="float: left; padding:0; margin-top: 5px; border-radius: 5px;  background: rgba(222,222,222,1);">
            <img src="../../css/images/my9time-logo%201.png" style="width: 100px"></a>
        <!-- Search bar -->
        <div id="search-bar" class="input-group hidden-xs">
            <input id="search-input" type="text" class="form-control" placeholder="{{'SEARCH'|translate}}"
                   ui-event="{keyup: 'autoSearch()'}" data-ng-model="searchQuery">

            <div class="input-group-btn">
                <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
            </div>
        </div>
        <!-- search result -->
        <div id="search-result">
            <span data-ng-show="searching && openSearchBox"><i class="fa fa-spinner fa-spin fa-2x"></i></span>
            <!-- list user -->
            <ul id="user-result" data-ng-show="!searching && searchQuery && (resultUser.length > 0)">
                <li data-ng-repeat="user in resultUser">
                    <a href="/timeshelf/{{user.id}}">
                        <img ng-src="{{user.avatar}}" height="30" width="30"/>
                        <h4>{{user.username}}</h4>

                        <p>{{user.fullName}}</p>
                    </a>
                </li>
            </ul>

            <!-- list event -->
            <ul id="event-result" data-ng-show="!searching && searchQuery && (resultEvent.length > 0)">
                <li data-ng-repeat="event in resultEvent">
                    <a href="/event/view/{{event.id}}">
                        <img src="../../css/images/small-logo.png" width="30" style="background: rgba(122,122,122,0.5)"/>
                        <h4>{{event.name}}</h4>

                        <p>{{event.start | dateTimeFilter:'full'}}</p>
                    </a>
                </li>
            </ul>
        </div>

        <div class="new-event hidden-xs">
            <button class="btn-style" data-ng-click="openCreateEventPopup()">
                {{'BUTTON_CREATE_EVENT'|translate}}
            </button>
        </div>
    </div>


    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse navbar-ex1-collapse" id="sidebar">
        <div id="header">
            <div class="top">
                <!-- noti -->
                <div class="noti" data-ng-init="initNotification()">
                    <!-- EVENT REQUEST -->
                    <a class="event-request-icon" data-ng-click="loadEventRequestNotification()">
                        <div class="count" data-ng-hide="eventRequestUnreadCount == 0">{{eventRequestUnreadCount}}
                        </div>
                    </a>

                    <div class="event-request-item">
                        <h6 data-ng-if="eventRequestNotifications.length == 0" style="padding-left: 30%;">
                            {{'NOTI_NULL_EVENT'|translate}}</h6>
                        <ul class="root" data-ng-if="eventRequestNotifications.length > 0">
                            <li data-ng-repeat="eventRequest in eventRequestNotifications">
                                <a ng-class="{'noti-active':eventRequest.isSeen}" href="/event/view/{{eventRequest.eventId}}">
                                    <span class="image avatar-micro">
                                        <img ng-src="{{eventRequest.image}}"/>
                                    </span>
                                    <span class="noti-body" data-ng-if="!eventRequest.isInvitation">
                                        <b class="user-name">{{eventRequest.username}}</b> {{'NOTI_JOIN'|translate}} <b>{{eventRequest.eventName}}</b>
                                    </span>
                                    <span class="noti-body" data-ng-if="eventRequest.isInvitation">
                                        {{'NOTI_INVITE'|translate}} <b>{{eventRequest.eventName}}</b>
                                    </span>
                                </a>
                                <button class="btn-style cancel-btn"
                                        data-ng-click="rejectEventRequest(eventRequest.eventId,eventRequest.userId)">
                                    {{'BUTTON_CANCEL'|translate}}
                                </button>
                                <button class="btn-style" data-ng-click="confirmEventRequest(eventRequest.eventId,eventRequest.userId)">
                                    {{'BUTTON_CONFIRM'|translate}}
                                </button>
                            </li>
                        </ul>
                    </div>
                    <!-- FRIEND REQUEST -->
                    <a class="friend-request-icon" data-ng-click="loadFriendRequestNotification()">
                        <div class="count" data-ng-hide="friendRequestUnreadCount == 0">{{friendRequestUnreadCount}}
                        </div>
                    </a>

                    <div class="friend-request-item">
                        <h6 data-ng-if="friendRequestNotifications.length == 0" style="padding-left: 30%;">
                            {{'NOTI_NULL_FRIEND'|translate}}</h6>
                        <ul class="root" data-ng-if="friendRequestNotifications.length > 0">
                            <li data-ng-repeat="friendRequest in friendRequestNotifications">
                                <a ng-class="{'noti-active':friendRequest.isSeen}" href="/timeshelf/{{friendRequest.userId}}">
                                    <span class="image avatar-micro">
                                        <img ng-src="{{friendRequest.image}}"/>
                                    </span>
                                    <span class="noti-body">
                                        <b class="user-name">{{friendRequest.username}}</b> {{'NOTI_SEND'|translate}}
                                    </span>
                                </a>
                                <button class="btn-style cancel-btn" data-ng-click="rejectFriendRequest(friendRequest.id)">
                                    {{'BUTTON_CANCEL'|translate}}
                                </button>
                                <button class="btn-style" data-ng-click="confirmFriendRequest(friendRequest.id)">
                                    {{'BUTTON_CONFIRM'|translate}}
                                </button>
                            </li>
                        </ul>
                    </div>
                    <!-- MESSAGE --->
                    <a class="message-icon" data-ng-click="loadMessageNotification()">
                        <div class="count" data-ng-hide="messageUnreadCount == 0">{{messageUnreadCount}}</div>
                    </a>

                    <div class="message-item">
                        <h6 data-ng-if="messageNotifications.length == 0" style="padding-left:30%">
                            {{'NOTI_NULL_MESSAGE'|translate}}</h6>
                        <ul class="root" data-ng-if="messageNotifications.length > 0">
                            <li data-ng-repeat="message in messageNotifications">
                                <a href="/messages">
                                    <span class="image avatar-micro"><img ng-src="{{message.image}}" alt=""></span>
                                        <span class="noti-body">
                                            <b class="user-name">{{message.username}}</b>
                                            {{message.content}}<br/>
                                            <i class="noti-date">{{message.lastUpdatedDate | timeAgoFilter}}</i>
                                        </span>
                                </a>
                            </li>
                        </ul>
                    </div>
                    <!-- NOTIFICATION -->
                    <a class="noti-icon" data-ng-click="loadNotification()">
                        <div class="count" data-ng-hide="notificationUnreadCount == 0">{{notificationUnreadCount}}</div>
                    </a>

                    <div class="notification-item">
                        <h6 data-ng-if="notifications.length == 0" style="padding-left:30%">{{'NOTI_NULL' | translate}}</h6>
                        <ul class="root" data-ng-if="notifications.length > 0">
                            <li data-ng-repeat="notification in notifications">
                                <!--comment notificatioin-->
                                <a ng-class="{'noti-active':!notification.isRead}" href="/event/view/{{notification.content.event}}"
                                   data-ng-if="notification.type == 'cmt'">
                                    <span class="image avatar-micro">
                                        <img ng-src="{{notification.content.image}}" alt=""/>
                                    </span>
                                    <span class="noti-body">
                                        {{notification.content.senderUsername | multiUserOnNotification}} {{'NOTI_COMMENT'| translate}} <b>{{notification.content.eventName}}</b><br/>
                                        <i class="noti-date">{{notification.createDate | timeAgoFilter}}</i>
                                    </span>
                                </a>

                                <!--updateEventIntro notification-->
                                <a ng-class="{'noti-active':!notification.isRead}" href="/event/view/{{notification.content.event}}"
                                   data-ng-if="notification.type == 'uptIntro'">
                                    <span class="image avatar-micro">
                                        <img ng-src="{{notification.content.image}}" alt=""/>
                                    </span>
                                    <span class="noti-body">
                                        {{notification.content.senderUsername | multiUserOnNotification}} {{'NOTI_INTRO' | translate}} <b>{{notification.content.eventName}}</b><br/>
                                        <i class="noti-date">{{notification.createDate | timeAgoFilter}}</i>
                                    </span>
                                </a>

                                <!--updateAnnouncement notification-->
                                <a ng-class="{'noti-active':!notification.isRead}" href="/event/view/{{notification.content.event}}"
                                   data-ng-if="notification.type == 'uptAnnoun'">
                                                    <span class="image avatar-micro">
                                                        <img ng-src="{{notification.content.image}}" alt=""/>
                                                    </span>
                                                    <span class="noti-body">
                                                        {{notification.content.senderUsername | multiUserOnNotification}} {{'NOTI_ANNOUN' | translate}} <b>{{notification.content.eventName}}</b><br/>
                                                        <i class="noti-date">{{notification.createDate | timeAgoFilter}}</i>
                                                    </span>
                                </a>

                                <!--updateLike notification-->
                                <a ng-class="{'noti-active':!notification.isRead}" href="/event/view/{{notification.content.event}}"
                                   data-ng-if="notification.type == 'uptLike'">
                                        <span class="image avatar-micro">
                                            <img ng-src="{{notification.content.image}}" alt=""/>
                                        </span>
                                        <span class="noti-body">
                                            {{notification.content.senderUsername | multiUserOnNotification}} {{'NOTI_LIKE'|translate}} <b>{{notification.content.eventName}}</b><br/>
                                            <i class="noti-date">{{notification.createDate | timeAgoFilter}}</i>
                                        </span>
                                </a>

                                <!-- notification for friend request -->
                                <a ng-class="{'noti-active':!notification.isRead}" href="/timeshelf/{{notification.content.id}}"
                                   data-ng-if="notification.type == 'frco'">
                                                    <span class="image avatar-micro">
                                                        <img ng-src="{{notification.content.image}}" alt=""/>
                                                    </span>
                                                    <span class="noti-body">
                                                        <b>{{notification.content.username}}</b> {{'NOTI_FRIEND_CONFIRMED'| translate}}
                                                    </span>
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
                <!-- avatar-header -->
                <div id="avatar-header">
                    <span class="image avatar-large"><a href="/profile/{{global.userId}}"><img ng-src="{{global.avatar}}" alt=""/></a></span>

                    <h1 id="user-name"><a href="/profile/{{global.userId}}">{{global.username}}</a></h1>
                    <span class="byline"><a href="/profile/{{global.userId}}">{{global.fullName}}</a></span>
                    <a id="log-out" href="/logout" ng-click="logout()"><i class="fa fa-power-off fa-fw"></i>{{'BUTTON_LOGOUT'|translate}}</a>
                </div>

                <!-- Nav -->

                <ul class="nav navbar-nav">
                    <li><a href="/" id="top-link">{{'BUTTON_HOME'|translate}}<i
                            class="fa fa-home"></i></a>
                    </li>
                    <li class="active"><a href="/messages">{{'BUTTON_MESSAGE'|translate}}<i
                            class="fa fa-envelope"></i></a></li>
                    <li><a href="/timeshelf/{{userId}}">{{'BUTTON_MYTIMESHELF'|translate}}<i class="fa fa-user"></i></a>
                    </li>
                    <li><a href="/calendar">{{'BUTTON_CALENDAR' | translate}}<i class="fa fa-th"></i></a>
                    </li>
                </ul>


                <!-- Recent Event -->
                <div>
                    <ul class="nav nav-tabs" id="right-tab">
                        <li id="tab-recent-event" class="active"><a href="#recent-event" data-toggle="tab"><b>{{'RECENT_EVENT'|translate}}</b></a>
                        </li>
                        <li id="tab-suggest-friend"><a href="#suggest-friend" data-toggle="tab"><b>{{'SUGGEST_FRIEND'|translate}}</b></a></li>
                        </li>
                    </ul>

                    <div class="tab-content">

                        <div class="tab-pane active" id="recent-event" data-ng-init="getRecentEvent()">
                            <div class="item">
                                <a href="/event/view/{{post.eventID}}"
                                   data-ng-repeat="post in recentEvent"><b>{{post.name}}</b></a>
                            </div>
                        </div>

                        <div class="tab-pane" id="suggest-friend" data-ng-init="getRecommendFriends()">
                            <div class="item" ng-show="gettingRecommendFriends">
                                <p>
                                    <span><i class="fa fa-spinner fa-spin"></i></span>
                                </p>
                            </div>
                            <div class="item" ng-show="!gettingRecommendFriends">
                                <a href="/timeshelf/{{user.id}}"
                                   data-ng-repeat="user in recommendFriends"><img ng-src="{{user.avatar}}" width="30" height="30" style="float: left"> <b>{{user.username}}</b></a>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Language -->
            <div class="language-select">
                <p>{{'LANGUAGE' | translate}}
                    <a href="" ng-click="setLang('en')"><img src="/css/images/language/United-States.png"></a>
                    <a href="" ng-click="setLang('vi')"><img src="/css/images/language/Vietnam.png"></a>
                </p>
                <!--<a href="#" ng-click="setLang('en')">{{'BUTTON_ENGLISH' | translate}}</a>-->
                <!--<a href="#" ng-click="setLang('vi')">{{'BUTTON_VIETNAMESE' | translate}}</a>-->
            </div>
        </div>
    </div>
    <!-- /.navbar-collapse -->
</nav>
<!-- nav -->
<div id="page-wrapper">


    <!-- To-do list -->
    <div class="tdl-spmenu tdl-spmenu-vertical tdl-spmenu-right" id="tdl-spmenu-s2" >
        <div id="btn" data-ng-click="openTodo()"></div>
        <button class="btn-style" data-toggle="modal" data-target="#new-todo-modal" style="display: none"><i class="fa fa-plus fa-fw"></i>New</button>
        <div class="to-do-body">
            <style>
                .done-true {
                    text-decoration: line-through;
                }
            </style>
            <div ng-controller="todolistController" data-ng-init="getTodo()" class="to-do-list">
                <button class="btn-style" ng-click="archive()" tooltip="{{'CLEAN'|translate}}"><i class="fa fa-eraser" ></i></button>
                <h1 style="margin-bottom:10px">{{'REMAINING'|translate}} {{remaining()}}/{{todos.length}}</h1>

                <form ng-submit="addTodo()" style="padding: 10px" >
                    <button class="btn-style" type="submit"
                            tooltip="{{'ADD'|translate}}"><i class="fa fa-plus"></i></button>
                    <input type="text" ng-model="content" class="form-control" style="width: 75%;"
                           placeholder="{{'ADD_TODO'|translate}}" required maxlength="100">
                </form>

                <ul class="to-do-item">
                    <li ng-repeat="todo in todos">
                        <button class="btn-style" ng-click="removeTodo(todo)" tooltip="{{'DELETE'|translate}}"><i class="fa fa-minus-square"></i></button>
                        <input type="checkbox" ng-model="todo.status" data-ng-click="changeStatusTodo(todo)">
                        <span class="done-{{todo.status}}">{{todo.content}}</span>
                    </li>
                </ul>

            </div>
            <div>

            </div>
        </div>
    </div>


    <!-- message -->
    <div class="row" data-ng-controller="messageAllController">
        <div id="message">
            <!-- Friend list -->
            <div class="col-md-4">
                <h1>Friend List</h1>
                <!-- friend list or recently chat -->
                <input type="radio" name="showRecentChat" data-ng-model="leftPanelStatus" data-ng-click="leftPanelInit('rc')" value="rc" > recent chat
                <input type="radio" name="showFriendList" data-ng-model="leftPanelStatus" data-ng-click="leftPanelInit('fl')" value="fl" > friend list
                <!-- friend -->
                <div id="m-friends" data-ng-init="leftPanelInit('rc')">
                    <h1 data-ng-if="leftPanelStatus == 'rc' && friends.length == 0">You have not chatted yet.</h1>
                    <h1 data-ng-if="leftPanelStatus == 'fl' && friends.length == 0">You have no friend.</h1>
                    <!-- friend list -->
                    <div class="m-f-item" data-ng-if="leftPanelStatus == 'fl'" data-ng-repeat="friend in friends" data-ng-click="getChatLog(friend.userId,friend.username,friend.avatar)">
                        <span class="image avatar-large">
                            <img ng-src="{{friend.avatar}}" alt=""/>
                        </span>
                        <h1>{{friend.username}}</h1>
                        <span class="byline" data-ng-if="friend.lastMessage">{{friend.lastMessage}}</span>
                    </div>
                    <!-- recent chat -->
                    <div class="m-f-item" data-ng-if="leftPanelStatus == 'rc'" a data-ng-repeat="friend in friends" data-ng-click="getChatLogById(friend.conversationId)">
                        <span class="image avatar-large">
                            <img ng-src="{{friend.image}}" alt=""/>
                        </span>
                        <h1>{{friend.participant | participantArrayToString}}</h1>
                        <!--<span class="byline" data-ng-if="friend.lastMessage">{{friend.lastMessage}}</span>-->
                    </div>
                </div>
            </div>

            <!-- Message -->
            <div class="col-md-8">
                <h1>Messages</h1>
                <div id="m-conversations" data-ng-init="getRecentConversation()">
                    <h1 data-ng-if="viewConversation.length == 0">There is no conversation</h1>
                    <div ng-class="part.sender.userId | whoAmIFilter" data-ng-repeat="part in viewConversation" data-ng-if="viewConversation.length > 0">
                        <span class="image avatar-small"><img ng-src="{{part.sender.avatar}}" alt=""/></span>
                        <span class="byline">
                            <span data-ng-repeat="message in part.messages">
                                <i class="time">{{message.createDate | timeAgoFilter}}</i><p>{{message.message}}</p>
                            </span>
                        </span>
                    </div>
                </div>
            </div>

            <!-- enter text -->
            <div class="col-md-8" id="m-chat">
                <div class="new-textarea">
                    <form name="replyForm" novalidate="" mi-submit="reply(message)">
                        <textarea placeholder="Write a text..." data-ng-model="form.message" ng-disabled="participant.length==0"></textarea>
                        <button type="submit" class="btn-style textarea-btn" ng-disabled="participant.length==0">Send</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!-- /.row -->
</div>
</div>
